package org.spbsu.apco.common.task.impl;

import org.spbsu.apco.common.data.impl.PrimeInputVal;
import org.spbsu.apco.common.task.core.TaskDescriptor;
import org.springframework.util.Assert;

import java.util.Arrays;

/**
 * User: mikpan
 * Date: 1/21/13
 * Time: 7:57 PM
 */
public class PrimeFindTaskDescriptor extends TaskDescriptor {
    private Integer n;
    private Integer d;
    private Integer p;

    public PrimeFindTaskDescriptor(int n, int d, int p) {
        setTaskDescriptor(new PrimeFindTask());
        setInput(Arrays.asList(new PrimeInputVal(n, d, p)));
    }

    public PrimeFindTaskDescriptor() {
    }

    public void setN(int n) {
        this.n = n;
    }

    public void setD(int d) {
        this.d = d;
    }

    public void setP(int p) {
        this.p = p;
    }


    @Override
    public void afterPropertiesSet() throws Exception {
        Assert.notNull(n, "Number of primes not set for PrimeFindTaskDescriptor. Check configuration file.");
        Assert.notNull(d, "Number of digits not set for PrimeFindTaskDescriptor. Check configuration file.");
        Assert.notNull(p, "Precision not set for PrimeFindTaskDescriptor. Check configuration file.");
        setTaskDescriptor(new PrimeFindTask());
        setInput(Arrays.asList(new PrimeInputVal(n, d, p)));
    }
}
